package  org.fantasy.common.db.center;

import  org.fantasy.common.compile.CompileCenter;
import  org.fantasy.common.exception.DBException;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class QryCenterImpl extends AbstractQryCenter {
    
    private static final Log log = LogFactory.getLog(QryCenterImpl.class);
    
    public QryCenterImpl(String queryId, Map<String, Object> paramMap) {
        super(queryId, paramMap);
    }

    private CompileCenter compileCenter;

    public void setCompileCenter(CompileCenter compileCenter) {
        this.compileCenter = compileCenter;
    }
    
    @Override
    public String getSql() throws DBException {
        try {
            return compileCenter.compile(queryId, paramMap);
        } catch (Exception e) {
            log.error(e);
            throw new DBException(e);
        }
    }

}
